//
//  BaseResponse.swift
//  BaseSwift
//
//  Created by ghwang on 2018/9/29.
//  Copyright © 2018年 ghwang. All rights reserved.
//

import Foundation

class API: NSObject {
    
    //发送验证码
    public static func sendCode(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.POSTRequest(url:Constant.SEND_CODE,parameter:params) {
            (response:ALResult<ALNetHTTPResponseAny>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseAny = response.value!
            success(base.result as Any)
        }
        
    }
    
    //登录
    public static func login(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.POSTRequest(url:Constant.LOGIN,parameter:params) {
            (response:ALResult<ALNetHTTPResponseObject<LoginResult>>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseObject<LoginResult> = response.value!
            success(base.result as Any)
        }
        
    }
    //首页推荐产品
    public static func home_recom_goods(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.GETRequest(url:Constant.HOME_RECOM_GOODS,parameter:params) {
            (response:ALResult<ALNetHTTPResponseObject<Page<ProductVo>>>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseObject<Page<ProductVo>> = response.value!
            success(base.result as Any)
        }
        
    }
    //首页推荐景点
    public static func home_recom_scenics(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.GETRequest(url:Constant.HOME_SCENIC,parameter:params) {
            (response:ALResult<ALNetHTTPResponseObject<Page<ScenicVo>>>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseObject<Page<ScenicVo>> = response.value!
            success(base.result as Any)
        }
        
    }
    //首页推荐线路
    public static func home_line(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.GETRequest(url:Constant.HOME_LINE,parameter:params) {
            (response:ALResult<ALNetHTTPResponseObject<Page<RouteVo>>>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseObject<Page<RouteVo>> = response.value!
            success(base.result as Any)
        }
        
    }
    //首页分类
    public static func home_category(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.GETRequest(url:Constant.HOME_CATEGORY,parameter:params) {
            (response:ALResult<ALNetHTTPResponseArray<Classisy>>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseArray<Classisy> = response.value!
            success(base.result as Any)
        }

        
    }
    //首页推荐帖子
    public static func home_topic(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.GETRequest(url:Constant.HOME_TOPIC,parameter:params) {
            (response:ALResult<ALNetHTTPResponseObject<Page<TopPic>>>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseObject<Page<TopPic>> = response.value!
            success(base.result as Any)
        }
        
    }
    //首页地图界面分页数据
    public static func home_category_list(params:[String:String],isSlience:Bool,success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.GETRequest(url:Constant.HOME_CATEGORY_LIST,parameter:params,isSlience:isSlience) {
            (response:ALResult<ALNetHTTPResponseObject<Page<CategoryVo>>>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseObject<Page<CategoryVo>> = response.value!
            success(base.result as Any)
        }
        
    }
    //首页分类详情数据
    public static func home_category_detail(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.GETRequest(url:Constant.HOME_CATEGORY_DETAIL,parameter:params) {
            (response:ALResult<ALNetHTTPResponseObject<CategoryVo>>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseObject<CategoryVo> = response.value!
            success(base.result as Any)
        }
        
    }
    //玩家产品
    public static func playGoods(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.GETRequest(url:Constant.PLAY_PRODUCTS,parameter:params) {
            (response:ALResult<ALNetHTTPResponseObject<Page<ProductVo>>>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseObject<Page<ProductVo>> = response.value!
            success(base.result as Any)
        }
        
    }
    //玩家产品详情
    public static func playDetail(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.GETRequest(url:Constant.PLAY_DETAILS,parameter:params) {
            (response:ALResult<ALNetHTTPResponseObject<ProductVo>>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseObject<ProductVo> = response.value!
            success(base.result as Any)
        }
        
    }
    //玩家产品类型
    public static func playClassisy(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.GETRequest(url:Constant.PLAY_CLASSISY,parameter:params) {
            (response:ALResult<ALNetHTTPResponseArray<Classisy>>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseArray<Classisy> = response.value!
            success(base.result as Any)
        }
        
    }
    
    //微社区
    public static func socialList(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.GETRequest(url:Constant.SOCIAL_LIST,parameter:params) {
            (response:ALResult<ALNetHTTPResponseObject<Page<TopPic>>>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseObject<Page<TopPic>> = response.value!
            success(base.result as Any)
        }
        
    }
    //微社区详情
    public static func socialDetail(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.GETRequest(url:Constant.SOCIAL_DETAIIL,parameter:params) {
            (response:ALResult<ALNetHTTPResponseObject<TopPic>>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseObject<TopPic> = response.value!
            success(base.result as Any)
        }
        
    }
    //微社区发布
    public static func publishSocial(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.POSTRequest(url:Constant.PUBLISH_SOCIAL,parameter:params) {
            (response:ALResult<ALNetHTTPResponseObject<TopPic>>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseObject<TopPic> = response.value!
            success(base.result as Any)
        }
        
    }
    //微社区评论
    public static func socialComment(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.POSTRequest(url:Constant.SOCIAL_COMMENT,parameter:params) {
            (response:ALResult<ALNetHTTPResponseAny>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseAny = response.value!
            success(base.result as Any)
        }
        
    }
    
    //收藏
    public static func collect(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.POSTRequest(url:Constant.COLLECT,parameter:params) {
            (response:ALResult<ALNetHTTPResponseAny>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseAny = response.value!
            success(base.result as Any)
        }
        
    }
    //收藏列表
    public static func collectList(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.GETRequest(url:Constant.COLLECT_LIST,parameter:params) {
            (response:ALResult<ALNetHTTPResponseObject<Page<FavVo>>>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseObject<Page<FavVo>> = response.value!
            success(base.result as Any)
        }
        
    }
    //订单列表
    public static func orderList(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.GETRequest(url:Constant.ORDER_LIST,parameter:params) {
            (response:ALResult<ALNetHTTPResponseObject<Page<OrderVo>>>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseObject<Page<OrderVo>> = response.value!
            success(base.result as Any)
        }
        
    }
    
    //订单详情
    public static func orderDetail(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.GETRequest(url:Constant.ORDER_DETAIL,parameter:params) {
            (response:ALResult<ALNetHTTPResponseObject<OrderVo>>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseObject<OrderVo> = response.value!
            success(base.result as Any)
        }
        
    }
    //下单
    public static func maekOrder(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.POSTRequest(url:Constant.COMMIT_ORDER,parameter:params) {
            (response:ALResult<ALNetHTTPResponseObject<OrderVo>>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseObject<OrderVo> = response.value!
            success(base.result as Any)
        }
        
    }
    //产品评论
    public static func productComment(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.POSTRequest(url:Constant.PRODUCT_COMMENT,parameter:params) {
            (response:ALResult<ALNetHTTPResponseAny>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseAny = response.value!
            success(base.result as Any)
        }
        
    }
    //获取产品评论
    public static func productCommentList(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.GETRequest(url:Constant.PRODUCT_COMMENT_LIST,parameter:params) {
            (response:ALResult<ALNetHTTPResponseObject<Page<CommentVo>>>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseObject<Page<CommentVo>> = response.value!
            success(base.result as Any)
        }
        
    }
    
    //项目评论
    public static func projectComment(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.POSTRequest(url:Constant.PROJECT_COMMENT,parameter:params) {
            (response:ALResult<ALNetHTTPResponseAny>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseAny = response.value!
            success(base.result as Any)
        }
        
    }
    //项目产品评论列表
    public static func projectCommentList(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.GETRequest(url:Constant.PROJECT_COMMENT_LIST,parameter:params) {
            (response:ALResult<ALNetHTTPResponseObject<Page<CommentVo>>>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseObject<Page<CommentVo>> = response.value!
            success(base.result as Any)
        }
        
    }
    
    //获取产品日价
    public static func productDayPriceList(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.GETRequest(url:Constant.PRODUCT_DAYPRICE_LIST,parameter:params) {
            (response:ALResult<ALNetHTTPResponseArray<StockM>>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseArray<StockM> = response.value!
            success(base.result as Any)
        }
        
    }
    //提交x咨询
    public static func commitZiXun(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.POSTRequest(url:Constant.COMMIT_ZIXUN,parameter:params) {
            (response:ALResult<ALNetHTTPResponseAny>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseAny = response.value!
            success(base.result as Any)
        }
        
    }
    //咨询列表
    public static func zixunList(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.GETRequest(url:Constant.ZIXUN_LIST,parameter:params) {
            (response:ALResult<ALNetHTTPResponseObject<Page<ZiXunVo>>>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseObject<Page<ZiXunVo>> = response.value!
            success(base.result as Any)
        }
        
    }
    //我的帖子列表
    public static func myTopicList(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.GETRequest(url:Constant.MYTOPIC_LIST,parameter:params) {
            (response:ALResult<ALNetHTTPResponseObject<Page<TopPic>>>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseObject<Page<TopPic>> = response.value!
            success(base.result as Any)
        }
        
    }
    
    //我的帖子详情
    public static func myTopicDetail(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.GETRequest(url:Constant.MYTOPIC_DETAIL,parameter:params) {
            (response:ALResult<ALNetHTTPResponseAny>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseAny = response.value!
            success(base.result as Any)
        }
        
    }
    
    //退出登录
    public static func logout(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.POSTRequest(url:Constant.LOGOUT,parameter:params) {
            (response:ALResult<ALNetHTTPResponseAny>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseAny = response.value!
            success(base.result as Any)
        }
        
    }
    
    //删除我的帖子
    public static func delMyTopic(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.POSTRequest(url:Constant.DEL_MYTOPIC,parameter:params) {
            (response:ALResult<ALNetHTTPResponseAny>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseAny = response.value!
            success(base.result as Any)
        }
        
    }

    //个人资料修改
    public static func modifyPersonInfo(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.POSTRequest(url:Constant.MODIFY_PERSON_INFO,parameter:params) {
            (response:ALResult<ALNetHTTPResponseAny>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseAny = response.value!
            success(base.result as Any)
        }
        
    }
    //根据code获取用户信息
    public static func infoForCode(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.POSTRequest(url:Constant.INFOFORCODE,parameter:params) {
            (response:ALResult<ALNetHTTPResponseObject<LoginResult>>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseObject<LoginResult> = response.value!
            success(base.result as Any)
        }
        
    }
    //绑定手机号
    public static func bindPhone(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.POSTRequest(url:Constant.BIND_PHONE,parameter:params) {
            (response:ALResult<ALNetHTTPResponseObject<LoginResult>>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseObject<LoginResult> = response.value!
            success(base.result as Any)
        }
        
    }

    //支付订单
    public static func payOrder(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.POSTRequest(url:Constant.PAYORDER,parameter:params) {
            (response:ALResult<ALNetHTTPResponseAny>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseAny = response.value!
            success(base.result as Any)
        }
        
    }
    //刷新token
    public static func updateToken(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.POSTRequest(url:Constant.UPDATETOKEN,parameter:params) {
            (response:ALResult<ALNetHTTPResponseObject<LoginResult>>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseObject<LoginResult> = response.value!
            success(base.result as Any)
        }
        
    }
    //支付回调通知
    public static func payNotification(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.POSTRequest(url:Constant.PAYNOTIFICATION,parameter:params) {
            (response:ALResult<ALNetHTTPResponseAny>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseAny = response.value!
            success(base.result as Any)
        }
        
    }
    //取消订单
    public static func orderCancel(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.POSTRequest(url:Constant.ORDER_CANCEL,parameter:params) {
            (response:ALResult<ALNetHTTPResponseAny>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseAny = response.value!
            success(base.result as Any)
        }
        
    }
    //评论订单
    public static func orderComment(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.POSTRequest(url:Constant.ORDER_COMMENT,parameter:params) {
            (response:ALResult<ALNetHTTPResponseAny>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseAny = response.value!
            success(base.result as Any)
        }
        
    }
    //活动产品
    public static func activityProducts(params:[String:String],success:@escaping OnSuccess)
    {
        
        HTTPRequestManager.GETRequest(url:Constant.ACTIVITY_PRODUCTS,parameter:params,isSlience:true) {
            (response:ALResult<ALNetHTTPResponseArray<ActivisProduct>>) in
            
            guard response.isSuccess else{return}
            let base :ALNetHTTPResponseArray<ActivisProduct> = response.value!
            success(base.result as Any)
        }
        
    }
}
